//Page Object
Page({
  data: {
    address: {},
    cart: [],
    allCheck: true,
    allPrice: 0,
  },
  getCart(cart2) {
    let cart = cart2;
    cart.pics = [];
    cart.pics = cart2.pics[0];
    const allCheck = cart.length ? cart.every(v => v.checked) : false;
    let allPrice = 0;
    cart.forEach(item => {
      if (item.checked) {
        allPrice += item.goods_price * item.goods_num;
      }
    })
    this.setData({
      allPrice,
    })
    this.setData({
      cart,
      allCheck,
    })
    wx.setStorageSync("cart", cart2);
  },
  onShow() {
    let address = wx.getStorageSync("address") || {};
    if (JSON.stringify(address) === '{}') {
    } else {
      let cart2 = wx.getStorageSync("cart") || [];
      address.all = address.provinceName + address.cityName + address.countyName + address.detailInfo;
      this.setData({
        address,
      })
      this.getCart(cart2);
    }
  },
  jiesuan(){

  }
});